function UserTransactionsViewModel(userId){
	var self = this;
	self.purchasedProducts = ko.observableArray([]);
	self.soldProducts = ko.observableArray([]);
	
	self.onGetPurchasedSuccess = function(products) {
		self.purchasedProducts($.map(products.elements, function (productBuyed) { return new ProductBuyed(productBuyed); }));
	};
	
	self.onGetSoldSuccess = function(products) {
		self.soldProducts($.map(products.elements, function (productBuyed) { return new ProductBuyed(productBuyed); }));
	};
	
	self.purchasedProductPager = new Pager({
		webService: "product/getPurchasedProducts",
		params : { "userId" : userId, "pageNumber" : 1, "pageSize" : 5 },
		onSuccess: self.onGetPurchasedSuccess
	});
	
	self.soldProductPager = new Pager({
		webService: "product/getSoldProducts",
		params : { "userId" : userId, "pageNumber" : 1, "pageSize" : 5 },
		onSuccess: self.onGetSoldSuccess
	});
}

function ProductBuyed(productBuyedInfo){
	var self = this;
	self.product = new Product(productBuyedInfo.product);
	self.buyDate = productBuyedInfo.buyDate;
	self.formattedDate = productBuyedInfo.formattedDate;
	self.user = productBuyedInfo.user;
}